package com.qfmy.web.app.controller.listenBook;

import com.qfmy.common.result.Result;
import com.qfmy.model.vo.listenBook.AudioResourceVo;
import com.qfmy.web.app.service.listenBook.AudioResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.web.app.controller.listenBook
 * @date 2025/11/01
 * @description 听书
 */
@RestController
@RequestMapping("/app/listenBook")
@SuppressWarnings("ALL")
public class AudioResourceController {

    /**
     * 注入service
     */
    @Autowired
    private AudioResourceService audioResourceService;

    /**
     * 获取推荐榜数据
     */
    @RequestMapping("/getRecommendRank")
    public Result<List<AudioResourceVo>> getRecommendRank(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        List<AudioResourceVo> list = audioResourceService.getRecommendRank(pageNum, pageSize);
        return Result.ok(list);
    }

    /**
     * 获取热播榜
     */
    @RequestMapping("/getHotPlay")
    public Result<List<AudioResourceVo>> getHotPlay(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        List<AudioResourceVo> list = audioResourceService.getHotPlay(pageNum, pageSize);
        return Result.ok(list);
    }

    /**
     * 获取完结榜
     */
    @RequestMapping("/getFinish")
    public Result<List<AudioResourceVo>> getFinish(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        List<AudioResourceVo> list = audioResourceService.getFinish(pageNum, pageSize);
        return Result.ok(list);
    }

    /**
     * 获取最新作品
     */
    @RequestMapping("/getNewestAudio")
    public Result<List<AudioResourceVo>> getNewestAudio() {
        List<AudioResourceVo> list = audioResourceService.getNewestAudio();
        return Result.ok(list);
    }

    /**
     * 分页获取爆款新书
     */
    @RequestMapping("/getHotNewBooks")
    public Result<List<AudioResourceVo>> getHotNewBooks(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        List<AudioResourceVo> list = audioResourceService.getHotNewBooks(pageNum, pageSize);
        return Result.ok(list);
    }

    /**
     * 获取经典听书
     */
    @RequestMapping("/getClassicAudio")
    public Result<List<AudioResourceVo>> getClassicAudio() {
        List<AudioResourceVo> list = audioResourceService.getClassicAudio();
        return Result.ok(list);
    }

    /**
     * 分页获取猜你喜欢的数据
     */
    @RequestMapping("/getGuessYouLikeAudio")
    public Result<List<AudioResourceVo>> getGuessYouLike(@RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        List<AudioResourceVo> list = audioResourceService.getGuessYouLike(pageNum, pageSize);
        return Result.ok(list);
    }


    /**
     * 根据音频id获取音频
     */
    @RequestMapping("/getAudioById")
    public Result<AudioResourceVo> getAudioById(@RequestParam Long audioId) {
        AudioResourceVo audioResourceVo = audioResourceService.getAudioById(audioId);
        return Result.ok(audioResourceVo);
    }

    /**
     * 根据音频id查询相似的音频
     */
    @RequestMapping("/getSimilarAudio")
    public Result<List<AudioResourceVo>> getSimilarAudio(@RequestParam Long audioId) {
        List<AudioResourceVo> list = audioResourceService.getSimilarAudio(audioId);
        return Result.ok(list);
    }

    /**
     * 收索音频
     */
    @RequestMapping("/searchAudio")
    public Result<List<AudioResourceVo>> searchAudio(@RequestParam String keyword) {
        List<AudioResourceVo> list = audioResourceService.searchAudio(keyword);
        return Result.ok(list);
    }



}
